home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-21 | 5.3 KB | 183 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWBmpShp.h
- // Release Version: $ 1.0d1 $
- //
- // Creation Date: 4/11/94
- //
- // Copyright: © 1994 by Apple Computer, Inc., all rights reserved.
- //
- // Work to do
- // - Add GWorld flags to FW_SBitmap for Mac users
- //
- //========================================================================================
-
- #ifndef FWBMPSHP_H
- #define FWBMPSHP_H
-
- #ifndef FWSHAPE_H
- #include "FWShape.h"
- #endif
-
- #ifndef FWBNDSHP_H
- #include "FWBndShp.h"
- #endif
-
- // ----- Macintosh Includes -----
-
- #if defined(FW_BUILD_MAC) && !defined(__QDOFFSCREEN__)
- #include <QDOffScreen.h>
- #endif
-
- //========================================================================================
- // •• Forward Declarations
- //========================================================================================
-
- class FW_CGraphicContext;
- class FW_CBitmapShapeRep;
- class FW_CPictShape;
-
- //========================================================================================
- // •• struct FW_SBitmapInfo
- //========================================================================================
-
- struct FW_SBitmapInfo
- {
- short width;
- short height;
- short rowBytes;
- short pixelSize; // 1, 2, 4, 8, 16 or 32
- };
-
- //========================================================================================
- // •• CLASS FW_CBitmapShape
- //========================================================================================
-
- class FW_CBitmapShape : public FW_CShape
- {
- //----------------------------------------------------------------------------------------
- // • Constructors
- //
- public:
- FW_CBitmapShape();
- FW_CBitmapShape(short width, short height, short pixelSize, const FW_CRect& rect = FW_kZeroRect);
- FW_CBitmapShape(char* image, short width, short height, short rowbytes, short pixelSize, const FW_CRect& rect = FW_kZeroRect);
-
- FW_CBitmapShape(const FW_CBitmapShape& other);
- FW_CBitmapShape(FW_CBitmapShapeRep* rep);
-
- FW_CBitmapShape(FW_PlatformPict platformPicture, const FW_CRect& rect = FW_kZeroRect);
-
- //----------------------------------------------------------------------------------------
- // • Operators
- //
- public:
- FW_CBitmapShape& operator=(const FW_CBitmapShape& other);
- FW_CBitmapShape& operator=(FW_CBitmapShapeRep* other);
- FW_CBitmapShapeRep* operator->() const
- {return (FW_CBitmapShapeRep*)GetRep();}
-
- //----------------------------------------------------------------------------------------
- // • Conversion
- //
- public:
- operator FW_CPictShape() const;
- };
-
- //========================================================================================
- // •• class FW_CBitmapShapeRep
- //========================================================================================
-
- class FW_CBitmapShapeRep : public FW_CBoundedShapeRep
- {
- friend class FW_CBitmapShape;
-
- //----------------------------------------------------------------------------------------
- // • Constructors/Destructors
- //
- protected:
- FW_CBitmapShapeRep();
- FW_CBitmapShapeRep(char* image,
- short width, short height,
- short rowbytes, short pixelSize,
- const FW_CRect& rect);
-
- FW_CBitmapShapeRep(FW_PlatformPict platformPicture, const FW_CRect& rect);
-
- virtual ~FW_CBitmapShapeRep();
-
- //---------------------------------------------------------------------------------------
- // • Inherited API
- //
- public:
- // ----- Hit Testing -----
- virtual FW_HitTestPart HitTest(const FW_CPoint& test) const;
-
- // ----- Rendering -----
- virtual void Draw(FW_CGraphicContext* graphicContext);
-
- // ----- Default shape -----
- virtual void SetAsDefault() const;
-
- // ----- Stream -----
- virtual void Flatten(FW_CWritableStream& stream);
- virtual void Unflatten(FW_CReadableStream& stream);
-
- //---------------------------------------------------------------------------------------
- // • New API
- //
- public:
- FW_CBitmapShape Copy() const;
-
- long GetPixel(short x, short y) const;
- long GetPixel(short x, short y, FW_CColor& color) const;
-
- void SetPixel(short x, short y, long index);
- void SetPixel(short x, short y, const FW_CColor& color);
-
- void GetBitmapInfo(short& width, short& height,
- short& rowBytes, short& pixelSize) const;
- void ChangeBitmap(char* image,
- short width, short height,
- short rowBytes, short pixelSize);
-
- FW_CBitmapShape GetBitmapParts(const FW_CRect& bounds);
-
- void SetBitmapParts(const FW_CBitmapShape& bitmapShape, const FW_SPlatformRect& bounds);
- void SetBitmapParts(FW_PlatformPict platformPicture, const FW_SPlatformRect& bounds);
-
- void CopyPixels(const FW_CBitmapShape& dstShape,
- const FW_SPlatformRect& srcRect,
- const FW_SPlatformRect& dstRect);
-
- #ifdef FW_BUILD_MAC
- protected:
- GWorldPtr GetMacGWorld() const
- {return fMacGWorld;}
- private:
- void NewGWorld(short width, short height, short pixelSize);
- void MacSetImage(char* image, short rowbytes);
- void MacSetImage(PicHandle picture, const FW_SPlatformRect& dstRect);
- PixMapHandle LockPixels();
- #endif
-
- private:
- void ConvertToPict(FW_CPictShape& pictShape);
-
- //---------------------------------------------------------------------------------------
- // • Data Member
- //
- private:
- short fHeight;
- short fWidth;
-
- #ifdef FW_BUILD_MAC
- short fInitialPixelSize;
- GWorldPtr fMacGWorld;
- #endif
-
- #ifdef FW_BUILD_WIN
- #endif
- };
-
- #endif